package com.health.trans.annotation;

import cn.hutool.core.exceptions.ExceptionUtil;

import javax.validation.ConstraintValidatorContext;

/**
 * @author nqlz
 */
public class BaseHandler {
    public static void throwException(ConstraintValidatorContext context, String msg) {
        errMsg(msg, context);
        ExceptionUtil.wrapRuntimeAndThrow(msg);
    }

    public static boolean errMsg(String msg, ConstraintValidatorContext context) {
        //重新添加错误提示语句
        context.buildConstraintViolationWithTemplate(msg)
                .addConstraintViolation();
        return false;
    }
}
